
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Kafka的ACK机制有那些 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Kafka的ACK机制有那些 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Kafka的ACK机制是什么，它的主要作用体现在哪四个方面？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">ACK机制是生产者向Kafka集群发送消息时要求的确认机制。其主要作用体现在四个方面：1. 消息可靠性，确保消息被成功接收和写入；2. 消息顺序性，保证消息按发送顺序被接收；3. 消息一致性，确保消费者获取的是已成功写入的消息；4. 性能调节，允许根据业务需求权衡可靠性与性能。</div>
          </div>
          <div class="card-source">来源: 基本概念</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">请解释Kafka生产者`acks=0`配置的工作方式及其适用场景。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当`acks`设置为0时，生产者发送消息后不会等待来自服务器的任何确认。这种配置下，消息可能会丢失，但吞吐量最高。它适用于对消息丢失不敏感、追求高性能的场景。</div>
          </div>
          <div class="card-source">来源: 生产端确认机制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Kafka生产者的`acks=all`配置如何保证最高的消息可靠性？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当`acks`设置为`all`时，生产者发送消息后会等待ISR（In-Sync Replicas，同步副本集）中的所有副本都确认收到了消息，才认为消息发送成功。这提供了最高的消息可靠性，但可能会牺牲一定的性能。</div>
          </div>
          <div class="card-source">来源: 生产端确认机制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Java代码中配置Kafka生产者时，应该使用哪个配置项来设置ACK机制？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在Java代码中，应该使用`ProducerConfig.ACKS_CONFIG`常量来设置ACK机制。例如：`configProps.put(ProducerConfig.ACKS_CONFIG, "all");`。</div>
          </div>
          <div class="card-source">来源: 生产端确认机制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Kafka消费端存在哪两种确认机制（偏移量管理方式）？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">消费端的确认机制有两种：自动提交偏移量（Automatic Offset Commit）和手动提交偏移量（Manual Offset Commit）。消费者可以根据业务需求选择合适的方式来管理偏移量。</div>
          </div>
          <div class="card-source">来源: 消费端确认机制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">使用自动提交偏移量机制可能会带来什么问题？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">自动提交偏移量可能会导致偏移量提交不准确。如果消费者在处理消息时发生错误，并且在自动提交偏移量之前发生故障，就可能导致一些消息被重复消费或者丢失。</div>
          </div>
          <div class="card-source">来源: 消费端确认机制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">相比自动提交，手动提交偏移量的主要优势是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">手动提交偏移量的主要优势是更加灵活。消费者可以根据实际的业务逻辑和处理结果来决定何时提交偏移量，从而确保偏移量提交的准确性，有效避免消息重复消费或丢失的问题。</div>
          </div>
          <div class="card-source">来源: 消费端确认机制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Kafka生产者的`acks=1`配置提供了怎样的可靠性保证？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当`acks`设置为1时，生产者发送消息后会等待ISR（In-Sync Replicas）中的至少一个副本（通常是leader副本）确认消息，然后将消息视为已成功发送。这种配置在可靠性和性能之间提供了一个平衡。</div>
          </div>
          <div class="card-source">来源: 生产端确认机制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在SpringBoot应用的配置文件中，如何将Kafka生产者的ACK机制设置为最高可靠性？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在SpringBoot的`application.properties`或`application.yml`文件中，可以通过设置`spring.kafka.producer.acks=all`来让生产者采用最高的确认机制。</div>
          </div>
          <div class="card-source">来源: 生产端确认机制</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
